package com.bitoon.basketdudes.jpa;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author paco FELC 2010
 */
@Entity
@Table(name = "m_carta", schema = "basket")
@NamedQueries({
    @NamedQuery(name = "MCarta.findAll",        query = "SELECT m FROM MCarta m"),
    @NamedQuery(name = "MCarta.findActivas",    query = "SELECT c FROM MCarta c WHERE (estado=1 or estado=2) order by id"),
    @NamedQuery(name = "MCarta.findById",       query = "SELECT m FROM MCarta m WHERE m.id = :id"),
    @NamedQuery(name = "MCarta.findByNombre",   query = "SELECT m FROM MCarta m WHERE m.nombre = :nombre"),
    @NamedQuery(name = "MCarta.findByCategoriaId", query = "SELECT m FROM MCarta m WHERE m.categoriaId = :categoriaId")})

public class MCarta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Short id;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "categoria_id")
    private short categoriaId;
    @Basic(optional = false)
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "mCarta")
    private Collection<Carta> cartaCollection;

    public MCarta() {
    }

    public MCarta(Short id) {
        this.id = id;
    }

    public MCarta(Short id, String nombre, short categoriaId, int duracionBase) {
        this.id = id;
        this.nombre = nombre;
        this.categoriaId = categoriaId;
    }

    public Short getId() {
        return id;
    }

    public void setId(Short id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public short getCategoriaId() {
        return categoriaId;
    }

    public void setCategoriaId(short categoriaId) {
        this.categoriaId = categoriaId;
    }

    public Collection<Carta> getCartaCollection() {
        return cartaCollection;
    }

    public void setCartaCollection(Collection<Carta> cartaCollection) {
        this.cartaCollection = cartaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MCarta)) {
            return false;
        }
        MCarta other = (MCarta) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.jpa.MCarta[id=" + id + "]";
    }

}
